<?php if(!defined("HDPHP_PATH"))exit;C("SHOW_NOTICE",FALSE);?><!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>蘑菇街-购物车</title>
	<script type='text/javascript' src='http://localhost/HDPHP/hdphp/hdphp/Extend/Org/Jquery/jquery-1.8.2.min.js'></script>
<link href='http://localhost/HDPHP/hdphp/hdphp/Extend/Org/hdjs/hdui/css/hdui.css' rel='stylesheet' media='screen'>
<script src='http://localhost/HDPHP/hdphp/hdphp/Extend/Org/hdjs/hdui/js/hdui.js'></script>
<link href='http://localhost/HDPHP/hdphp/hdphp/Extend/Org/hdjs/hdvalidate/css/hdvalidate.css' rel='stylesheet' media='screen'>
<script src='http://localhost/HDPHP/hdphp/hdphp/Extend/Org/hdjs/hdvalidate/js/hdvalidate.js'></script>
<script src='http://localhost/HDPHP/hdphp/hdphp/Extend/Org/cal/lhgcalendar.min.js'></script>
<script src='http://localhost/HDPHP/hdphp/hdphp/Extend/Org/hdjs/hdslide/js/hdslide.js'></script>
<script type='text/javascript'>
HOST = 'http://localhost';
ROOT = 'http://localhost/me/12.6/ccl_eshop/Eshop';
WEB = 'http://localhost/me/12.6/ccl_eshop/Eshop/index.php';
URL = 'http://localhost/me/12.6/ccl_eshop/Eshop/index.php/Index/Cart/index';
APP = 'http://localhost/me/12.6/ccl_eshop/Eshop/Eshop';
COMMON = 'http://localhost/me/12.6/ccl_eshop/Eshop/Eshop/Common';
HDPHP = 'http://localhost/HDPHP/hdphp/hdphp';
HDPHPDATA = 'http://localhost/HDPHP/hdphp/hdphp/Data';
HDPHPEXTEND = 'http://localhost/HDPHP/hdphp/hdphp/Extend';
MODULE = 'http://localhost/me/12.6/ccl_eshop/Eshop/index.php/Index';
CONTROLLER = 'http://localhost/me/12.6/ccl_eshop/Eshop/index.php/Index/Cart';
ACTION = 'http://localhost/me/12.6/ccl_eshop/Eshop/index.php/Index/Cart/index';
STATIC = 'http://localhost/me/12.6/ccl_eshop/Eshop/Static';
HDPHPTPL = 'http://localhost/HDPHP/hdphp/hdphp/Lib/Tpl';
VIEW = 'http://localhost/me/12.6/ccl_eshop/Eshop/Eshop/Index/View';
PUBLIC = 'http://localhost/me/12.6/ccl_eshop/Eshop/Eshop/Index/View/Public';
CONTROLLERVIEW = 'http://localhost/me/12.6/ccl_eshop/Eshop/Eshop/Index/View/Cart';
HISTORY = 'http://localhost/me/12.6/ccl_eshop/Eshop/index.php/Index/Index/goods/gid/5';
</script>
	<hdconst/>	
	<style type="text/css">
		span{
			cursor: pointer;
		}
	</style>
	<link rel="stylesheet" href="http://localhost/me/12.6/ccl_eshop/Eshop/Eshop/Index/View/Public/Css/cart.css">
</head>
<body>
	<div id="top">
		<div class="inside">
			<div class="top_left">
				<div class="img"></div>
				<a href="">蘑菇街首页</a>
			</div>
			<div class="right">
				<div class="log_reg">
					<?php if($_SESSION['user']['uname']){?>
					<a href="">欢迎:&nbsp&nbsp<?php echo $_SESSION['user']['uname'];?>&nbsp&nbsp登录蘑菇街</a>
					<a href="<?php echo U('Login/out');?>" class='login'>退出</a>
					<?php  }else{ ?>
					<a href="<?php echo U('Login/login');?>">登录</a>
					<a href="">注册</a>
					<?php }?>
				</div>
				<!-- <div class="in_rig">
					<div class="cart_img"></div>
					<a href="" class="cart_g">帮助中心</a>
				</div>	 -->			
			</div>
		</div>
	</div>
	<div id="wrap">
		<div id="title">
				<div class="tit_one">
					<div class="in"></div>
				</div>
				<div class="tit_two">
					
				</div>
				<div class="tit_three">
					<div class="process">
						<div class="first"><p>1</p></div>
						<div class="second"> <p>2</p></div>
						<div class="third"><p>3</p></div>
					</div>
				</div>
		</div>
		<div id="ad">
			<div class="inside">
				<img src="http://localhost/me/12.6/ccl_eshop/Eshop/Eshop/Index/View/Public/Images/32.jpg" alt="">
				<ul class="cartSlide">
					<li><a href=""  class="c_one">全部商品</a></li>
					<li><a href="">优惠</a></li>
					<li><a href="">库存紧张</a></li>
				</ul>
			</div>
		</div>

		<div class="cart_goods">
			<table class="cartOrderTable">
				<thead>
					<tr>
						<th class="tab_one">
							<input type="checkbox">
							<label for="">全选</label>
						</th>
						<th class="tab_two">
							商品
						</th>
						<th class="tab_three">
							商品信息
						</th>
						<th class="tab_four">
							单价
						</th>
						<th class="tab_five">
							数量
						</th>
						<th class="tab_six">
							小计
						</th>
						<th class="tab_seven">
							操作
						</th>						
					</tr>
					
					<tr>
						<td class="tab_td_one">
							<input type="checkbox">
							<label for="">全选</label>
						</td>
						<td class="tab_td_two">
							青春如诗
							<img src="http://localhost/me/12.6/ccl_eshop/Eshop/Eshop/Index/View/Public/Images/1.gif" alt="">
						</td>
					</tr>
					<!-- 购物车商品 -->

					<?php $hd["list"]["c"]["total"]=0;if(isset($_SESSION['cart']['goods']) && !empty($_SESSION['cart']['goods'])):$_id_c=0;$_index_c=0;$lastc=min(1000,count($_SESSION['cart']['goods']));
$hd["list"]["c"]["first"]=true;
$hd["list"]["c"]["last"]=false;
$_total_c=ceil($lastc/1);$hd["list"]["c"]["total"]=$_total_c;
$_data_c = array_slice($_SESSION['cart']['goods'],0,$lastc);
if(count($_data_c)==0):echo "";
else:
foreach($_data_c as $key=>$c):
if(($_id_c)%1==0):$_id_c++;else:$_id_c++;continue;endif;
$hd["list"]["c"]["index"]=++$_index_c;
if($_index_c>=$_total_c):$hd["list"]["c"]["last"]=true;endif;?>

					<tr id='<?php echo $c['cart_id'];?>'>
						<td class="tab_td_lou1_one">
							<input type="checkbox">
						</td>
						<td class="tab_td_lou1_two">
							<img src="http://localhost/me/12.6/ccl_eshop/Eshop/<?php echo $c['pic'];?>" alt="">
							<a href=""><?php echo $c['goods_name'];?></a>
						</td>
						<td class="tab_td_lou1_three">
							<p>颜色:</p>
							<p>尺码:<?php echo $c['attr_value'][1];?></p>
						</td>
						<td class="tab_td_lou1_four">
							<p>155.71:</p>
							<p class="one_price"><?php echo $c['price'];?></p>
							<span>促销7.0折</span>
						</td>
						<td class="tab_td_lou1_five">
							<span class="h30" onclick="changePrice(this,0);">[-]</span>
							<input type="text" name='num' value="<?php echo $c['num'];?>" class="w50 h30">
							<span class="h30" onclick="changePrice(this,1);">[+]</span>
						</td>
						<td class="tab_td_lou1_six">
							<p class="one_price"><?php echo $c['totalPrice'];?></p>
						</td>
						<td class="tab_td_lou1_seven">
							<a href="">删除</a>
						</td>
					</tr>
					<?php $hd["list"]["c"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
				</thead>
			</table>
			<div class="cartPaybar">
				<div class="cp_left">
					<div class="cp_in">
						<input type="checkbox" id='cp_l_i'>
						<label for="cp_l_i">全选</label>
						<a href="">删除</a>
						<a href="">清空失效商品</a>
					</div>
				</div>
				<div class="cp_right">
					<div class="cart_paybar_info">
						共有<span class='total_num' style='color:#F36;font-size:16px'><?php echo $_SESSION['cart']['totalNum'];?></span>件商品，总计(全国免运费):
					</div>
					<span class="goods_sum"><?php echo number_format($_SESSION['cart']['totalPrice'],2); ?> </span>
					<a href="<?php echo U('Order/index');?>" class="payBtn"></a>
				</div>
			</div>
		</div>
		
	</div>
	<!-- js效果 -->
	<script type="text/javascript">
	function changePrice(obj,action){
		//将input标签中的内容转化成整数
		var num=$(obj).siblings('input').val()*1;
		if(action){
			//数量加
			$(obj).siblings('input').val(num+1);
			// 小计
			price=$(obj).parent('td').siblings('td.tab_td_lou1_four').find('p.one_price').html()*1*(num+1);
			$(obj).parent('td').siblings('td.tab_td_lou1_six').find('p').html(price);
			//算总价
			var totalPrice=0;
			$('td.tab_td_lou1_six').each(function(i) {
				totalPrice+=$(this).find('p').html()*1;
			});
			$('.goods_sum').html(totalPrice.toFixed(2));
		}else{
			//数量减
			// num=Math.max(1,num-1);
			if(num<2) return;
			//小计
			$(obj).siblings('input').val(num-1);
			price=$(obj).parent('td').siblings('td').find('p.one_price').html()*1*(num-1);
			$(obj).parent('td').siblings('td.tab_td_lou1_six').find('p').html(price);
			//算总价
			var totalPrice=0;
			$('td.tab_td_lou1_six').each(function(i) {
				totalPrice+=$(this).find('p').html()*1;
			});
			$('.goods_sum').html(totalPrice.toFixed(2));
		}
			$.ajax({
			url:CONTROLLER+'&a=changeNum',
			data:{cart_id:cart_id,num:num},
			type:'post',
			dataType:'json',
		})
	}

	// function changePrice(obj,action){
	// 	var num=$(obj).siblings('input').val()*1;
	// 	if (action) {
	// 		// if () {};
	// 		price=$(obj).parent('td').siblings('td.tab_td_lou1_four').find('p.one_price').html()*1*(num+1);
	// 		$(obj).parent('td').siblings('td.tab_td_lou1_six').find('p').html(price);
	// 		$(obj).siblings('input').val(num+1);
	// 		//算总价
	// 		var totalPrice=0;
	// 		$('td.tab_td_lou1_six').each(function(i) {
	// 			totalPrice+=$(this).find('p').html()*1;
	// 		});
	// 		$('span.goods_sum').html(totalPrice.toFixed(2));
	// 	}else{
	// 		if (num<2) return;
	// 		price=$(obj).parent('td').siblings('td.tab_td_lou1_four').find('p.one_price').html()*1*(num-1);
	// 		$(obj).parent('td').siblings('td.tab_td_lou1_six').find('p').html(price);
	// 		$(obj).siblings('input').val(num-1);
			
	// 	}
	// }


	// function changePrice(obj,action){
	// 	var num=$('#'+cart_id).find('input').val()*1;
	// 	var price=$('#'+cart_id).find('.price').html()*1;
	// 	var totprice=$('#'+cart_id).find('.totprice').html();
	// 	totprice=parseInt(totprice);
	// 	// alert(price);
	// 	if(action){
	// 		$('#'+cart_id).find('input').val(num+1);
	// 		pricehtml=(parseInt(num)+1)*parseInt(price);
	// 		// alert($(this).parent('td').siblings('td.totprice').html(pricehtml+'.00'));
	// 		$('#'+cart_id).find('.totprice').html(pricehtml+'.00');
	// 	}else{
	// 		num=Math.max(1,num-1);
	// 		$('#'+cart_id).find('input').val(num);
	// 		// alert(num);
	// 	}
	// 	// alert(num);
	// 	$.ajax({
	// 		url:CONTROLLER+'&a=changeNum',
	// 		data:{cart_id:cart_id,num:num},
	// 		type:'post',
	// 		dataType:'json',
	// 	})
	// }

	</script>
</body>
</html>